//
//  HYTabBarController.m
//  自定义tabBar
//
//  Created by students on 16/2/18.
//  Copyright (c) 2016年 1000Phone. All rights reserved.
//

#import "HYTabBarController.h"
#import "HYTabBar.h"
@interface HYTabBarController ()<HYTabBarDelegate>
@property(nonatomic, strong)NSMutableArray *items;
@end

@implementation HYTabBarController
-(NSMutableArray *)items
{
    if (_items==nil)
    {
        _items=[NSMutableArray array];
    }
    return _items;
}
- (void)viewDidLoad
{
    [super viewDidLoad];
    HYTabBar *myTabBar=[[HYTabBar alloc]init];
    _hyTabBar=myTabBar;
    myTabBar.frame=self.tabBar.frame;
    [self.tabBar removeFromSuperview];
    myTabBar.delegate=self;
    myTabBar.backgroundColor=[UIColor blueColor];
    [self.view addSubview:myTabBar];
       UIViewController *controlOne=[[UIViewController alloc]init];
    controlOne.view.backgroundColor=[UIColor redColor];
    [self setAllViewController:controlOne Title:@"one" imageName:@"message.png" selectImageName:@"message_hl.png"];
    UIViewController *controlTwo=[[UIViewController alloc]init];
    controlTwo.view.backgroundColor=[UIColor blueColor];
    [self setAllViewController:controlTwo Title:@"two" imageName:@"linkman.png" selectImageName:@"linkman_hl.png"];
    UIViewController *controlThree=[[UIViewController alloc]init];
    controlThree.view.backgroundColor=[UIColor blackColor];
    [self setAllViewController:controlThree Title:@"three" imageName:@"development.png" selectImageName:@"development_hl.png"];
    UIViewController *controlFour=[[UIViewController alloc]init];
    controlFour.view.backgroundColor=[UIColor yellowColor];
    [self setAllViewController:controlFour Title:@"four" imageName:@"skin_tab_icon_call_normal.png" selectImageName:@"skin_tab_icon_call_selected.png"];
   self.viewControllers=@[controlOne,controlTwo,controlThree,controlFour];
    self.hyTabBar.HYitems=self.items;
}
- (void)setAllViewController:(UIViewController *)viewControll Title:(NSString *)title imageName:(NSString *)imgName selectImageName:(NSString *)selectImgName
{
    
    viewControll.tabBarItem.title=title;
    viewControll.tabBarItem.image=[UIImage imageNamed:imgName];
    viewControll.tabBarItem.selectedImage=[UIImage imageNamed:selectImgName];
    [self.items addObject:viewControll.tabBarItem];
}
-(void)didBtnClickChangeControl:(HYTabBar *)tabBar Index:(NSInteger)index
{
    self.selectedIndex=index;
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
